package com.suixinsanren.design.observer.demo02;

public class AverageDisplay implements Display, Observer {

    private String date;
    private String maxTemperature;
    private String minTemperature;
    private String remark;

    @Override
    public void update(String date, String maxTemperature, String minTemperature, String remark) {
        this.date = date;
        this.maxTemperature = maxTemperature;
        this.minTemperature = minTemperature;
        this.remark = remark;
        display();
    }

    @Override
    public void display() {
        double averageTemperature = (Double.parseDouble(maxTemperature) + Double.parseDouble(minTemperature)) / 2.0;
        System.out.println("今天是" + date + ",平均温度:" + averageTemperature + "," + remark);
    }
}
